import { request } from '@/utils/request';
import {PageParams} from "@/api/model/pageParams";


// 分页
export const page = async (params: PageParams) =>
  request.post({ url: '/sysUser/page', params });

// 新增
export const insert = async (data: any) =>
  request.post({ url: '/sysUser/insert', data });

//更新
export const update = async (data: any) =>
  request.put({ url: '/sysUser/update', data });

// 删除
  
export const deleteById = async (id: string) => {
  try {
    const response = await request.delete({ url: `/sysUser/delete/${id}` });
    // 处理响应
  } catch (error) {
    // 处理错误
    console.error('删除失败:', error);
  }
};

//查询单个用户
export const getUser = async (id: string) =>
  request.get({ url: '/sysUser/InfoUser/${id}'});

// 分页
export const list = async (params: PageParams) =>
  request.post({ url: '/sysUser/list', params });

// 踢人下线
export const kickUserOut = async (id: string) =>
  request.post({ url: `/sysUser/kickUserOut?id=${id}` });

//重置密码
export const resetPassword = async (id: string) =>
  request.post({ url: `/sysUser/resetPassword?id=${id}` });

// 修改密码
export const changePassword = async (oldPassword: string, newPassword: string) =>
  request.put({ url: '/sysUser/changePassword', data: { oldPassword, newPassword } });